var users=[];
var zTreeObj;
var setting = {
	async : {
		enable : true,
		url : "../../../business/component!ztree",
		autoParam : ["id=bean.id"],
		otherParam:{
			"settingId.name":wfsetting.name,
		    "settingId.stepId":wfsetting.stepId,
		    "settingId.actionId":wfsetting.actionId,
		    "mapDefaultActionMethod":false
		    
		}
	

	},
	callback: {
	    onAsyncSuccess: zTreeOnAsyncSuccess,
	    onClick:zTreeOnClick
	}
};
var root = {
  	  name : "西安庆华特种能源有限公司西安庆华公司",
		  open : true,
		  nocheck:true,
		  id:"root",
		  isParent:true
  } ;
var zNodes = [
     root                      
            ];
function filter(treeId, parentNode, childNodes) {
	if (!childNodes)
		return null;
	for ( var i = 0, l = childNodes.length; i < l; i++) {
		childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
	}
	return childNodes;
}
function beforeAsync(treeId, treeNode) {
	return true;
}
function zTreeOnAsyncSuccess(event, treeId, treeNode, msg){
	
	//alert(treeId);
	
}

function zTreeOnClick(event, treeId, treeNode) {
    if(treeNode.isParent==false){
    	action['username'] = treeNode.id;   
    }   
}

function submitwork(){
	var url = "../../../workflow/proceed/proceed!proceed";
	var ps = "workflowId="+action['workflowId']+"&actionId="+action['actionId']+"&nextOwners[0].owner="+action['username']+"&nextOwners[0].stepId="+action['stepId'];
	if(action['username']==""){
		alert("请先选择一个办理人");
		return;
	}
	
	$.post(url,ps,function(){
	    window.location.href="../../../index.jsp";
	});
}


$(function() {
	//initToolbars() 
	zTreeObj = $.fn.zTree.init($("#usersTree"), setting,zNodes);
	var nodes = zTreeObj.getNodes();
	zTreeObj.expandNode(nodes[0]);	
	
});
